package sctu.edu.java.year2016.team01.xuhanmei.day20160611;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * Created by Administraiptor on 2016/6/12..
 */
public class Address {
    public static void main(String[] args) {
        InetAddress ip;
        try {
            ip=InetAddress.getLocalHost();
            String localname=ip.getHostName();//获取主机名
            String localip=ip.getHostAddress();//获取主机ip地址
            System.out.println("本地主机名："+localname);
            System.out.println("本地ip地址："+localip);
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }
}
